<?php

/**
 * This is the model class for table "ab_projects".
 *
 * The followings are the available columns in table 'ab_projects':
 * @property integer $Id
 * @property string $project_title
 * @property integer $project_category
 * @property string $project_start
 * @property string $project_end
 * @property string $project_content
 * @property integer $project_state
 * @property integer $customer_id
 */
class Projects extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Projects the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ab_projects';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('project_category, project_state, customer_id', 'numerical', 'integerOnly'=>true),
			array('project_title', 'length', 'max'=>255),
			array('project_start, project_end, project_content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('Id, project_title, project_category, project_start, project_end, project_content, project_state, customer_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'project_title' => 'Project Title',
			'project_category' => 'Project Category',
			'project_start' => 'Project Start',
			'project_end' => 'Project End',
			'project_content' => 'Project Content',
			'project_state' => 'Project State',
			'customer_id' => 'Customer',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('project_title',$this->project_title,true);
		$criteria->compare('project_category',$this->project_category);
		$criteria->compare('project_start',$this->project_start,true);
		$criteria->compare('project_end',$this->project_end,true);
		$criteria->compare('project_content',$this->project_content,true);
		$criteria->compare('project_state',$this->project_state);
		$criteria->compare('customer_id',$this->customer_id);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}